package com.cdks.wuxiu.api.service.mysql;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdks.wuxiu.api.component.constant.Constant;
import com.cdks.wuxiu.api.mapper.ScoreAwardConfigMapper;
import com.cdks.wuxiu.api.util.TimeUtils;
import com.cdks.wuxiu.entity.mysql.ScoreAwardConfig;

import org.springframework.stereotype.Service;


/**
 * 积分奖励配置表 服务实现类
 */
@Service
public class ScoreAwardConfigServiceImpl extends ServiceImpl<ScoreAwardConfigMapper, ScoreAwardConfig> implements ScoreAwardConfigService {
    @Override
    public ScoreAwardConfig getByType(int type) {
        String now  = TimeUtils.getLocalDateTime("HH:mm:ss");
        QueryWrapper<ScoreAwardConfig> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ScoreAwardConfig::getType, type)
                        .le(ScoreAwardConfig::getStartTime, now)
                        .ge(ScoreAwardConfig::getStopTime, now)        
                        .eq(ScoreAwardConfig::getStatus, Constant.DATA_STATUS_ENABLE);                      

        return baseMapper.selectOne(wrapper);
    }
}
